package basic;

public class ImoocStudent1 {
    String nickname;
    String position;
    String city;
    String sex;
    // 无参构造方法
    public void StudyCourse() {
        System.out.println("学习课程");
    }

    public void PostComment() {
        System.out.println("发表评论");
    }

    public void PostArtion() {
        System.out.println("发表手记");
    }
    // 有参构造方法
    public ImoocStudent1 (String studentNickname, String studentPosition,String studentCity, String studentSex) {
//      成员属性的命名和参数变量的命名是不同的
        nickname = studentNickname;
        position = studentPosition;
        city = studentCity;
        sex = studentSex;
    }
//    在方法内部，this 关键字是当前对象的默认引用
//    this 关键字可以解决实例变量和参数变量冲突的问题
//   public ImmocStudent1(String nickname) {
//       this.nickname = nickname;
//}



    public static void main(String[] args) {

        ImoocStudent1 student1 = new ImoocStudent1("James","工程师","shanghai","male");
        System.out.println("昵称：" + student1.nickname);
        System.out.println("昵称：" + student1.position);
        System.out.println("昵称：" + student1.city);
        System.out.println("昵称：" + student1.sex);
        student1.StudyCourse();
        student1.PostComment();
        student1.PostArtion();
    }
}
